In a computer system, instructions are typically fetched from a program memory, decoded and supplied to an execution unit where they are executed to run the programs stored in the program memory. It is frequently the case where a particular sequence of instructions is required to be executed more than once, sometimes dependent on certain conditional parameters being met. Such sequences are termed herein “loops”. Loops can be implemented by software, by instructions which, after the end of a particular sequence of instructions constituting a loop has been reached, cause the first instruction of the loop to be executed again. So-called software loops are assisted by associated hardware, in particular in the form of a loop end register which holds the address of the last instruction in the loop, and a loop start register which holds the address of the first instruction in the loop. By loading these registers, loops can be automatically executed a predetermined number of times by the computer system. That is, if the loop end address is detected, the next address which is fetched from memory is the loop start address. A loop count register holds an initial number which is the number of times the loop is to be executed, and is decremented each time a loop is carried out.
One problem with such hardware loops is that the same instructions are being repeatedly fetched from memory, with consequential use of power and load on the memory access buses.
It is an aim of the present invention to obviate this where possible.